<?php

namespace App\Http\Services;

use App\Http\Model\Hint;
use App\Http\Model\Settle;

class SettleServices extends CommonServices
{
    protected $settleModel;

    public function __construct()
    {
        $this->settleModel = new Settle();
    }

    //公会结算审核
    public function unionSettleAudit($id, $status, $audit_msg)
    {
        $code = Hint::SUCCESS;
        $msg = '';
        $data = [];
        do {
            //获取公会结算记录
            $info = $this->settleModel->getUnionSettleById($id);
            if(empty($info)) {
                $code = Hint::PARAM_ERROR;
                $msg = '获取公会结算记录失败';
                break;
            }
            if(!in_array($info['status'], [2, 3, 5])) {
                $code = Hint::PARAM_ERROR;
                $msg = '公会结算记录当前状态不支持后台修改';
                break;
            }

            $this->settleModel->updateUnionSettle($info['id'], ['status'=>$status, 'audit_msg'=>$audit_msg]);
        } while (false);

        return compact('code', 'msg', 'data');
    }


}
